﻿<?php
if(!defined('IN_PHPSCUP'))exit('hacking'); 
class CompanyModel extends BaseModel
{

    var $table  = 'company_msg';	

    var $_page_rows = 20;	
	
    /* 插入数据 */
    function post($data)
    {    
	
		$time = time();     
    
		return $this->IU_Sql_Exe(array ('data' => array('user_id'=>$data["user_id"],'cat_id'=>$data["cat_id"],'name'=>$data["name"],'title'=>$data["title"],'filename'=>$data["filename"],'filepath'=>$data["filepath"],'keywords'=>$data["keywords"],'description'=>$data["description"],'content'=>$data["content"],'add_time'=>"$time"), 'mode' => 'INSERT'));

        
    }


    function show($order='',$v='',$word='')
    {  
	     empty($order)?$order = ' posttime desc':'';
		 
   	    $conditions = " uid !='0' ";
		 
		 foreach($word as $key => $value)
		 {

		     if($value)
		     {
		      $conditions .= " and title like '%{$value}%' ";
	  
		     }
		 }	

	  
	      //分页时，一定是先调用page函数，再调用S_Sql_Exe函数
		 $info['page'] = $this->Page(array('conditions' =>"{$conditions}",'url' => 'admin/?app=company&act=index&v='.$v));		
		 
		 $info['data'] = $this->S_Sql_Exe(array('fields'=> ' * ','conditions' =>"{$conditions}",'order' =>"{$order}",'limit' =>$info['page']['sql_limit']));
    
		 return $info;
   
    }

    /* 删除数据 */
    function del($id ='')
    {      
		return $this->D_Sql_Exe(array ('conditions' =>"id = '{$id}' "));
        
    }

    /* 修改数据 */
    function editaction($id ='',$data = '')
    {    
		$time = time();  	      
		return $this->IU_Sql_Exe(array ('data' => array('user_id'=>$data["user_id"],'cat_id'=>$data["cat_id"],'name'=>$data["name"],'title'=>$data["title"],'filename'=>$data["filename"],'filepath'=>$data["filepath"],'keywords'=>$data["keywords"],'description'=>$data["description"],'content'=>$data["content"],'add_time'=>"$time"),'mode' => 'UPDATE','conditions' =>"id = '{$id}' "));
        
    }


    /* 通过id取出一条数据 */
    function oneshow($id ='')
    {    
	      
		 $info = $this->S_Sql_Exe(array('fields' =>'*','conditions' =>"id='{$id}'",'return' =>'one'));
    
		 return $info;
        
    }


}




?>